--------------------------------------------------------------------------
-- $File: //scripts/main.lua $
-- $Revision$
-- $Date$
-- $Author$
--
-- $Id$
--------------------------------------------------------------------------
-- This file is maintained as part of the SSM AEGIS project. All additions
-- are the sole work of their authors to which all copyright and ownership
-- resides. However, each author grants license for the use of his or her
-- work to be a part of the SSM AEGIS project.
--
--  (C), Daniel 'Rod-Serling' Phelps, 2008
--  (C), Terry 'Charlie' Reinert, 2008
--------------------------------------------------------------------------
--  This work is based off of:
--	(C), Ralf 'Hawkeye' Ullrich, 2008
--
--	Crytek Source File.
-- 	Copyright (C), Crytek Studios, 2001-2008.
--------------------------------------------------------------------------

function OnInit()
	Script.ReloadScript("scripts/common.lua");
	Script.ReloadScript("scripts/entities/actor/BasicActor.lua");
	Script.ReloadScript("Libs/ReverbPresets/ReverbPresetDB.lua");
	-- Script.ReloadScript("Libs/SoundPresets/PresetDB.lua"); not used
	Script.ReloadScript("scripts/physics.lua");
	Script.ReloadScript("scripts/Tweaks.lua");
end


function OnShutdown()
end

function PreloadForStats()
	Script.ReloadScript("scripts/gamerules/powerstruggle.lua");

	local params={
		position={x=0, y=0, z=0},
	};
	
	local properties={		
	};
	
	for i,v in pairs(PowerStruggle.buyList) do
		if (v.class) then
			params.class=v.class;
			if (v.vehicle and v.modification) then
				params.properties=properties;
				properties.Modification=v.modification;
			else
				params.properties=nil;
			end
			System.SpawnEntity(params);
			params.position.y=params.position.y+40;
			if (params.position.y>4000) then
				params.position.y=0;
				params.position.x=params.position.x+40;
			end
		end
	end
end
-- Aegis loader
System.LogAlways("[AEGIS] Attempting Intitial Loading.");

AEGIS = {};
AEGIS.NAME = "astrada";
Script.ReloadScript("Scripts/"..AEGIS.NAME.."/ServerModUtils.lua");
if(not AEGIS.Utils) then
    System.LogAlways("[AEGIS] FATAL ERROR: ServerModUtils.lua failed to load");
	System.Quit();
end
Script.ReloadScript("Scripts/"..AEGIS.NAME.."/ServerModInfo.lua");
if(not AEGIS.Info) then
    System.LogAlways("[AEGIS] FATAL ERROR: ServerModInfo.lua failed to load");
    System.Quit();
end
Script.ReloadScript("Scripts/"..AEGIS.NAME.."/ServerModDefaults.lua");
if(not AEGIS.Defaults) then
    System.LogAlways("[AEGIS] FATAL ERROR: ServerModDefaults.lua failed to load");
	System.Quit();
end
Script.ReloadScript("Scripts/"..AEGIS.NAME.."/ServerModMain.lua");
if(not AEGIS.Main) then
    System.LogAlways("[AEGIS] FATAL ERROR: ServerModMain.lua failed to load");
	System.Quit();
end

LogAlways("[AEGIS] %s loaded successfully.", AEGIS.VERSION);
System.ExecuteCommand("exec "..AEGIS.NAME..".cfg");
XSetupDirs();
XDebugCall(XReload, false);
XGetChatCommandFiles();

